package com.dyzx.hbb.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dyzx.hbb.modules.sys.entity.SysNoticeRead;
import com.dyzx.hbb.modules.sys.service.SysNoticeReadService;
import com.dyzx.hbb.modules.sys.mapper.SysNoticeReadMapper;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【sys_notice_read(创建阅读表)】的数据库操作Service实现
* @createDate 2025-04-22 17:48:54
*/
@Service
public class SysNoticeReadServiceImpl extends ServiceImpl<SysNoticeReadMapper, SysNoticeRead>
    implements SysNoticeReadService{

    @Override
    public boolean readNotice(Long id, Long userId) {
        LambdaQueryWrapper<SysNoticeRead> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(SysNoticeRead::getNoticeId, id)
                .eq(SysNoticeRead::getOperatorId, userId);
        queryWrapper.last("limit 1");
        SysNoticeRead one = this.getOne(queryWrapper);
        if (one != null) {
         one.setFlag(1);
         return this.updateById(one);
        }
        return false;
    }
}




